SET(PROJ_NAME stream_server)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/hal/net/include)
include_directories(${PROJECT_SOURCE_DIR}/foundation/media/include)
include_directories(${PROJECT_SOURCE_DIR}/foundation/web_server/include)

# find_path(BASICUSAGEENVIRONMENT_INCLUDE_DIR BasicUsageEnvironment.hh HINTS ${CMAKE_SYSROOT}/usr/include/BasicUsageEnvironment)
# find_path(GROUPSOCK_INCLUDE_DIR Groupsock.hh HINTS ${CMAKE_SYSROOT}/usr/include/groupsock)
# find_path(LIVEMEDIA_INCLUDE_DIR liveMedia.hh HINTS ${CMAKE_SYSROOT}/usr/include/liveMedia)
# find_path(USAGEENVIRONMENT_INCLUDE_DIR UsageEnvironment.hh HINTS ${CMAKE_SYSROOT}/usr/include/UsageEnvironment)
# include_directories(${BASICUSAGEENVIRONMENT_INCLUDE_DIR})
# include_directories(${GROUPSOCK_INCLUDE_DIR})
# include_directories(${LIVEMEDIA_INCLUDE_DIR})
# include_directories(${USAGEENVIRONMENT_INCLUDE_DIR})

# 初始化 ALL_SOURCES 变量
set(ALL_SOURCES "")

list(APPEND ALL_SOURCES "src/stream_server_init.cpp")

# file(GLOB_RECURSE LIVE555_SOURCES 
#     "src/live555/*.cpp" 
#     "src/live555/*.hpp" 
#     "src/live555/*.c" 
#     "src/live555/*.h"
# )
# list(APPEND ALL_SOURCES ${LIVE555_SOURCES})

find_path(GSTREAMER_INCLUDE_DIR gst/gst.h HINTS ${CMAKE_SYSROOT}/usr/include/gstreamer-1.0)
find_path(GLIB_INCLUDE_DIR glib.h HINTS ${CMAKE_SYSROOT}/usr/include/glib-2.0)
find_path(GLIBCONFIG_INCLUDE_DIR glibconfig.h HINTS ${CMAKE_SYSROOT}/usr/lib/glib-2.0/include)
find_path(GSTWEBRTC_INCLUDE_DIR gst/webrtc/webrtc.h HINTS ${CMAKE_SYSROOT}/usr/include/gstreamer-1.0)
find_path(GSTAPP_INCLUDE_DIR gst/app/gstappsrc.h HINTS ${CMAKE_SYSROOT}/usr/include/gstreamer-1.0)
find_path(GSTRTSP_INCLUDE_DIR gst/rtsp-server/rtsp-server.h HINTS ${CMAKE_SYSROOT}/usr/include/gstreamer-1.0)

include_directories(${GSTREAMER_INCLUDE_DIR})
include_directories(${GLIB_INCLUDE_DIR})
include_directories(${GLIBCONFIG_INCLUDE_DIR})
include_directories(${GSTWEBRTC_INCLUDE_DIR})
include_directories(${GSTAPP_INCLUDE_DIR})
include_directories(${GSTRTSP_INCLUDE_DIR})

file(GLOB_RECURSE GSTREAMER_SOURCES 
    "src/gstreamer/*.cpp" "src/gstreamer/*.hpp" "src/gstreamer/*.c" "src/gstreamer/*.h")
list(APPEND ALL_SOURCES ${GSTREAMER_SOURCES})

add_library(${PROJ_NAME} STATIC ${ALL_SOURCES})

target_link_libraries(${PROJ_NAME} PRIVATE
    # 基础系统库
    ffi
    pcre2-8

    # GLib依赖
    glib-2.0
    gobject-2.0
    gthread-2.0
    gmodule-2.0
    gio-2.0

    # GStreamer核心和功能库
    gstreamer-1.0
    gstbase-1.0
    gstapp-1.0
    gstsdp-1.0
    gstrtsp-1.0
    gstrtp-1.0
    gstrtspserver-1.0
    gstnet-1.0
    gstvideo-1.0
    gstpbutils-1.0
    gstaudio-1.0
    gsttag-1.0
    gstwebrtc-1.0
    gstwebrtcnice-1.0
    nice

    # live555库
    # BasicUsageEnvironment 
    # groupsock 
    # liveMedia
    # UsageEnvironment
)